package com.muyu.entity;

import com.muyu.group.AddGroup;
import com.muyu.group.UpdateGroup;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @ClassName: UserEntity
 * @Author: Zirun.Xin
 * @Date: 2025/4/7 下午2:40
 * @Version: 1.0
 * @Description: 用户实体
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserEntity {

    /**
     * 用户id
     */
    @NotNull(message = "用户id不能为空", groups = UpdateGroup.class)
    private Integer id;

    /**
     * 用户名称
     */
    @NotBlank(message = "用户名称不能为空", groups = {UpdateGroup.class, AddGroup.class})
    private String userName;

    /**
     * 年龄
     */

    @Min(value = 1, message = "年龄不能小于1", groups = {UpdateGroup.class, AddGroup.class})
    @Max(value = 150, message = "年龄不能超过150", groups = {UpdateGroup.class, AddGroup.class})
    @NotNull(message = "年龄不能为空", groups = {UpdateGroup.class, AddGroup.class})
    private Integer userAge;

    /**
     * 密码
     */
    @NotBlank(message = "密码不能为空", groups = {UpdateGroup.class, AddGroup.class})
    @Length(min = 6, max = 10, message = "密码长度至少6位但不能超过10位", groups = {UpdateGroup.class, AddGroup.class})
    private String userPwd;

    /**
     * 邮箱
     */
    @Email(message = "邮箱格式不正确", groups = {UpdateGroup.class, AddGroup.class})
    private String email;
}
